class Exploitdb < Formula
  desc "Database of public exploits and corresponding vulnerable software"
  homepage "https://www.exploit-db.com/"
  url "https://github.com/offensive-security/exploitdb.git",
      tag:      "2022-01-14",
      revision: "77bb25c902c444565fda18cc38f900cd9d143ff6"
  version "2022-01-14"
  license "GPL-2.0-or-later"
  head "https://github.com/offensive-security/exploitdb.git", branch: "master"

  bottle do
    sha256 cellar: :any_skip_relocation, arm64_monterey: "9c80263b4301f73e66ae193e0176f91c5c74899cf0aaf602ac9019aa03695a91"
    sha256 cellar: :any_skip_relocation, arm64_big_sur:  "6a7f69731e397429e578f78c28a3a10da21a95a37f6d76984e98f1a6864c2c86"
    sha256 cellar: :any_skip_relocation, monterey:       "c1949a512e2bcfa36b2f0fb5fd3dea2eb9628bacfd1e615a7003e3249ff3b20e"
    sha256 cellar: :any_skip_relocation, big_sur:        "267fd1c34bfba6f61ca4829f1fc2d16966f3f32865a697d0dc7516287d35c642"
    sha256 cellar: :any_skip_relocation, catalina:       "353ec432839669d8dd96e43054c5e2e54561ba774225c8ae39eb93215828559d"
    sha256 cellar: :any_skip_relocation, x86_64_linux:   "2773d5f9ef965ffdb4828bdf0a6a997f56f79f6ee0319af7f370113ddab1edab"
  end

  def install
    inreplace "searchsploit",
              "rc_file=\"\"", "rc_file=\"#{etc}/searchsploit_rc\""

    optpath = opt_share/"exploitdb"
    inreplace ".searchsploit_rc" do |s|
      s.gsub! "\"/opt/exploitdb\"", optpath
      s.gsub! "\"/opt/exploitdb-papers\"", "#{optpath}-papers"
    end

    bin.install "searchsploit"
    etc.install ".searchsploit_rc" => "searchsploit_rc"

    pkgshare.install %w[.git exploits files_exploits.csv files_shellcodes.csv
                        shellcodes]
  end

  test do
    system "#{bin}/searchsploit", "sendpage"
  end
end
